﻿//Hai hàm liên qua CheckAlls và CheckSingles

function CheckAlls(idCheckAll, nameCheckSingle, formId) {
    var length;
    if (document.forms[formId] != undefined) {
        length = document.forms[formId].length;
    } else {
        length = formId.length;
    }
    
    if (idCheckAll.checked == true || (document.getElementById(idCheckAll) != null && document.getElementById(idCheckAll).checked == true )) {
           
        for (var i = 0; i < length; i++) {
            var item;
            if (document.forms[formId] != undefined) {
                item = document.forms[formId].elements[i];
            } else {
                item = formId.elements[i];
            }
            if ((nameCheckSingle[0] != undefined) && (item.name == nameCheckSingle || item.name == nameCheckSingle[0].name) && item.type == 'checkbox') { //nameCheckSingle: 1- là tên của nhóm CheckSingle; 2- là nhóm checkbox có tên Sign
                item.checked = true;
            }
            if ((nameCheckSingle[0] == undefined) && (item.name == nameCheckSingle || item.name == nameCheckSingle.name) && item.type == 'checkbox') { //nameCheckSingle: 1- là tên của nhóm CheckSingle; 2- là nhóm checkbox có tên Sign
                item.checked = true;
            }
        }
    }
    else {
        for (var i1 = 0; i1 < length; i1++) {
            var item1;
            if (document.forms[formId] != undefined) {
                item1 = document.forms[formId].elements[i1];
            } else {
                item1 = formId.elements[i1];
            }

            if ((nameCheckSingle[0] != undefined) && (item1.name == nameCheckSingle || item1.name == nameCheckSingle[0].name) && item1.type == 'checkbox') {
                item1.checked = false;
            }
            if ((nameCheckSingle[0] == undefined) && (item1.name == nameCheckSingle || item1.name == nameCheckSingle.name) && item1.type == 'checkbox') {
                item1.checked = false;
            }
        }
    }
}

function GetAllValueIsChecked(nameCheckSingle, formId) {
    var listid = "";
    for (var i = 0; i < document.forms[formId].length; i++) {
        var item = document.forms[formId].elements[i];
        if (item.name == nameCheckSingle && item.type == 'checkbox' && item.checked == true) {
            listid += item.value + ",";
        }
    }
    if (!IsEmpty(listid))
        listid = listid.substring(0, listid.length - 1);
    return listid;
}

function CheckSingles(idCheckAll, nameCheckSingle, formId) {
    var length;
    if (document.forms[formId] != undefined) {
        length = document.forms[formId].length;
    } else {
        length = formId.length;
    }

    var isCheckAll = true;

    for (var i = 0; i < length; i++) {       
        var item;
        if (document.forms[formId] != undefined) {
            item = document.forms[formId].elements[i];
        } else {
            item = formId.elements[i];
        }
        if ((nameCheckSingle[0] != undefined) && (item.name == nameCheckSingle || item.name == nameCheckSingle[0].name) && item.type == 'checkbox' && item.checked == false) {
            isCheckAll = false;
            break;
        }
        if ((nameCheckSingle[0] == undefined) && (item.name == nameCheckSingle || item.name == nameCheckSingle.name) && item.type == 'checkbox' && item.checked == false) {
            isCheckAll = false;
            break;
        }
    }

    if (isCheckAll) {
        if (document.getElementById(idCheckAll) != null)
            document.getElementById(idCheckAll).checked = true;
        else
            idCheckAll.checked = true;

    } else {
        if (document.getElementById(idCheckAll) != null)
            document.getElementById(idCheckAll).checked = false;
        else
            idCheckAll.checked = false;
    }
}

//end


function Today() {
    var ngay, thang, nam;
    var thu;
    var full;
    var d = new Date();
    //ngày tháng nam
    ngay = d.getDate();
    thang = d.getMonth();
    thang++;
    nam = d.getFullYear();
    //Thứ
    var days = new Array("", "Chủ nhật", "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy");
    var wday = days[d.getDay() + 1];
    if (ngay < 10)
        ngay = '0' + new String(ngay);
    if (thang < 10)
        thang = '0' + new String(thang);
    var hours = d.getHours();
    var minutes = d.getMinutes();
    var seconds = d.getSeconds();
    var dn = "AM";
    if (hours >= 12) {
        dn = "PM";
        hours = hours;
        //this is so the hours written out is 
        //in 12-hour format, instead of the default //24-hour format.
    }
    //this is so the hours written out 
    //when hours=0 (meaning 12a.m) is 12
    if (minutes <= 9) {
        minutes = "0" + minutes;
    }
    if (seconds <= 9) {
        seconds = "0" + seconds;
    }
    full = hours + ":" + minutes + ":" + seconds + " " + dn + " | ";
    $("<span id='lblToday'>" + full + " " + wday + ', ' + ngay + '-' + thang + '-' + nam + "</span>")
		.replaceAll("#lblToday");
    setTimeout("Today()", 1000);
}


function ConvertDateToString(date) {
    var okDate = /Date\(([-+]?\d+[-+]?\d+)\)/ .exec(date);

    if (okDate) {
        var when = new Date(eval(okDate[1]));
        //da = new Date(date);  	// Create a Date Object set to the last modifed date
        var da = when;
        var dy = da.getFullYear();  	// Get full year (as opposed to last two digits only)
        var dm = da.getMonth() + 1;  	// Get month and correct it (getMonth() returns 0 to 11)
        var dd = da.getDate();  	// Get date within month
        if (dy < 1970) dy = dy + 100; 	// We still have to fix the millennium bug
        var ys = new String(dy); 	// Convert year, month and date to strings
        var ms = new String(dm);
        var ds = new String(dd);
        if (ms.length == 1) ms = "0" + ms; 	// Add leading zeros to month and date if required
        if (ds.length == 1) ds = "0" + ds;
        ys = ms + "/" + ds + "/" + ys;  	// Combine year, month and date in ISO format
        return ys;
    }
}

function Trim(sString) {
    while (sString.substring(0, 1) == " ") {
        sString = sString.substring(1, sString.length);
    }

    while (sString.substring(sString.length - 1, sString.length) == " ") {
        sString = sString.substring(0, sString.length - 1);
    }

    return sString;
}

function IsvalidDate(dateString, formatString) {
    if (dateString.indexOf("/") == -1) {
        return false;
    }
    var dt1 = dateString.split("/");
    var mm1 = parseInt(dt1[0]);
    var dd1 = parseInt(dt1[1]);
    var yy1 = parseInt(dt1[2]);
    if (isNaN(dd1) || isNaN(mm1) || isNaN(yy1)) {
        return false;
    }
    var dt2 = new Date(mm1 + '/' + dd1 + '/' + yy1);
    var dd2 = dt2.getDate();
    var mm2 = dt2.getMonth() + 1;
    var yy2 = dt2.getFullYear();

    if (dd1 == dd2 && mm1 == mm2 && yy1 == yy2)
        return true;
    else
        return false;
}


//function ConvertDateToString(curDt) {
//    var MM = curDt.getMonth() + 1;
//    MM = (MM < 10) ? '0' + MM : MM;
//    var dd = curDt.getDate();
//    dd = (dd < 10) ? '0' + dd : dd;
//    var yyyy = curDt.getFullYear();
//    var date = dd + '/' + MM + '/' + yyyy;

//    return date;
//}


// Dạng dd/MM/yyyy
function checkDateDDMMYYYY(dateString) {
 var marker = "/";
 var dateComp = dateString.split(marker);
    var now = new Date();
    //var yearNow = now.getFullYear();
    var dayInmonth = new Array(12);
    dayInmonth[0] = 31;
    dayInmonth[1] = 29;
    dayInmonth[2] = 31;
    dayInmonth[3] = 30;
    dayInmonth[4] = 31;
    dayInmonth[5] = 30;
    dayInmonth[6] = 31;
    dayInmonth[7] = 31;
    dayInmonth[8] = 30;
    dayInmonth[9] = 31;
    dayInmonth[10] = 30;
    dayInmonth[11] = 31;
    if (dateComp.length != 3) {
        //alert("Please enter correct date format for " + text + " (mm/dd/yyyy)!");
        return false;
    }
    for (var i = 0; i < 3; i++) {
        if (isNaN(dateComp[i])) {
            //alert("Please enter numeric for month, date, and year ( " + text + " )!");
            return false;
        }
    }
    if (dateComp[1] > 12 || dateComp[1] < 1) {
        //alert("Please enter a valid month for " + text + " (1 to 12)!");
        return false;
    }
//    if (dateComp[2] > yearNow + 1) {
//        //alert("Please enter a valid year for " + text + "! (future)");
//        return false;
//    }
//    if (dateComp[2] < yearNow - 1) {
//        //alert("Please enter a valid year for " + text + "! (past)");
//        return false;
//    }
    if (dateComp[2] % 4 == 0) {
        dayInmonth[1] = 29;
    }
    else {
        dayInmonth[1] = 28;
    }
    if (dateComp[0] > dayInmonth[dateComp[1] - 1] || dateComp[0] < 1) {
        //alert("Please enter a valid date!");
        return false;
    }

    return true;
}

function IsNumeric(sText) {
    var validChars = "0123456789/ ";
    var isNumber = true;
    var charr;
    for (var i = 0; i < sText.length && isNumber == true; i++) {
        charr = sText.charAt(i);
        if (validChars.indexOf(charr) == -1) {
            isNumber = false;
        }
    }
    return isNumber;
}

function ValidUserName(name) {
    name = name.replace(/(^\s*)|(\s*$)/g);
    var alphaExp = /^[0-9a-zA-Z]+$/;
    if (name.match(alphaExp)) {
        return true;
    } else {
        return false;
    }
}

function IsEmpty(value) {
    var isEmpty = false;
    if (value == null || value.length == 0) {
        isEmpty = true;
    }
    return isEmpty;
}

function emailCheck(email) {
    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email)) {
        email.focus();
        return false;
    }
}


function Popup(actionPath) {
    var winl = (screen.width - 600) / 2;
    var wint = (screen.height - 400) / 2;
    var newWindow = null;
    var mybars = "directories=no,location=no,menubar=no,status=no";
    mybars += ",titlebar='',toolbar=no,alwaysraised=no,maximize=no";
    var myoptions = "scrollbars=yes,top=" + wint + ",left=" + winl + ",width=600px,height=380px,resizable=no";
    var myfeatures = mybars + "," + myoptions;
    if (!newWindow || newWindow.closed()) {
        newWindow = window.open(actionPath, "FloatPopUp", myfeatures);
        newWindow.focus();
    }
}
function PopupPageWithMenuBar(Url, Width, Height) {
    var OffsetHeight = document.body.offsetHeight;
    var OffsettWidth = document.body.offsetWidth;
    var objWindow = window.open(Url, "", "width=" + Width + ",height=" + Height + ",resizable=1,scrollbars=yes, menubar=1");
    objWindow.moveTo((OffsettWidth - Width) / 2, (OffsetHeight - Height) / 2);
}

//Chuyển kiểu ngày dạng "dd/MM/yy" sang "MM/dd/yy"

function ConvertddMMyyyToMMddyy(dateString) {
    try {
        var ddMMyy = new Array();
        ddMMyy = dateString.split('/');
        
        if (ddMMyy.length != 3)
            return false;
        
        var MMddyy = ddMMyy[1] + "/" + ddMMyy[0] + "/" + ddMMyy[2];
        return MMddyy;
        
    } catch(e) {
        return false;
    }
}
//Chuyển kiểu ngày dạng "dd/MM/yy" sang "yy-MM-dd"
function DoiDinhDangNgayDDMMYYYYToYYYYMMDD(date) {
    var marker = "/";
    var dateComp = date.split(marker);
    return dateComp[2] + "-" + dateComp[1] + "-" + dateComp[0];
}

// Source: http://stackoverflow.com/questions/497790
var dates = {
    convert: function (d) {
        // Converts the date in d to a date-object. The input can be:
        //   a date object: returned without modification
        //  an array      : Interpreted as [year,month,day]. NOTE: month is 0-11.
        //   a number     : Interpreted as number of milliseconds
        //                  since 1 Jan 1970 (a timestamp) 
        //   a string     : Any format supported by the javascript engine, like
        //                  "YYYY/MM/DD", "MM/DD/YYYY", "Jan 31 2009" etc.
        //  an object     : Interpreted as an object with year, month and date
        //                  attributes.  **NOTE** month is 0-11.
        return (
            d.constructor === Date ? d :
            d.constructor === Array ? new Date(d[0], d[1], d[2]) :
            d.constructor === Number ? new Date(d) :
            d.constructor === String ? new Date(d) :
            typeof d === "object" ? new Date(d.year, d.month, d.date) :
            NaN
        );
    },
    compare: function (a, b) {
        // Compare two dates (could be of any type supported by the convert
        // function above) and returns:
        //  -1 : if a < b
        //   0 : if a = b
        //   1 : if a > b
        // NaN : if a or b is an illegal date
        // NOTE: The code inside isFinite does an assignment (=).
        return (
            isFinite(a = this.convert(a).valueOf()) &&
            isFinite(b = this.convert(b).valueOf()) ?
            (a > b) - (a < b) :
            NaN
        );
    },
    inRange: function (d, start, end) {
        // Checks if date in d is between dates in start and end.
        // Returns a boolean or NaN:
        //    true  : if d is between start and end (inclusive)
        //    false : if d is before start or after end
        //    NaN   : if one or more of the dates is illegal.
        // NOTE: The code inside isFinite does an assignment (=).
        return (
            isFinite(d = this.convert(d).valueOf()) &&
            isFinite(start = this.convert(start).valueOf()) &&
            isFinite(end = this.convert(end).valueOf()) ?
            start <= d && d <= end :
            NaN
        );
    }
}

String.prototype.replaceAll = function (
strTarget, // The substring you want to replace
strSubString // The string you want to replace in.
) {
    var strText = this;
    var intIndexOfMatch = strText.indexOf(strTarget);

    // Keep looping while an instance of the target string
    // still exists in the string.
    while (intIndexOfMatch != -1) {
        // Relace out the current instance.
        strText = strText.replace(strTarget, strSubString)

        // Get the index of any next matching substring.
        intIndexOfMatch = strText.indexOf(strTarget);
    }

    // Return the updated string with ALL the target strings
    // replaced out with the new substring.
    return (strText);
}

//...............................................................

//------------upload file


function GenAttrachFile() {
    var countUploadControl = Number($("#CountUploadControl").val()) + 1;
    $("#CountUploadControl").val(countUploadControl); // Tăng biến đếm số uploadControl lên 1
    var khaiBaoUploadControl = "<span id='DivAttrachFile" + countUploadControl
        + "'><br/><input type=\"file\" name=\"UploadControl\" id=\"AttrachFile" + countUploadControl + "\" size=\"53px\""
        + " onkeydown='CheckFileSize(" + countUploadControl + ")'"
        + " />"
        + "<img title='Xóa File đính kèm' style='cursor:pointer' src='/Content/Images/DeleteIcon.png' onclick='RemoveAttrachFile(" + countUploadControl + ")' /></span>";
    $("#TapTinDinhKemDiv").append(khaiBaoUploadControl);
}

function RemoveAttrachFile(uploadControlIndex) {
    $("#DivAttrachFile" + uploadControlIndex).remove();
}


//........................................................

function DisplayFileUpload(ListFileName, DuongDan, id, Controller, Action) {
    var DanhSachFileDaUpLoad = "";
    if (ListFileName != null) {
        var list = ListFileName.split("|");
        if (list.length > 0) {
            for (var i = 0; i < list.length; i++) {
                if (!IsEmpty(list[i])) {
                    DanhSachFileDaUpLoad += "<span id='file" + i + "'>"
                        + "<a target='_self' name='summary' href='/Download/DownloadFile?fileName="
                        + list[i].toString() + "&path=" + DuongDan + "' style='color: Blue;' >"
                        + list[i].toString() + "</a>&nbsp;";
                    if (!IsEmpty(Action)) {
                        DanhSachFileDaUpLoad += "<img title='Xóa File đính kèm' alt='Xóa File đính kèm' style='cursor:pointer' src='/Images/CrossDelete.png' onclick=\"javascript:DoDeleteAttachAjax("
                        + i + "," + id + ",'" + list[i] + "','" + Controller + "','" + Action + "');\" />;&nbsp&nbsp;"
                    }
                    DanhSachFileDaUpLoad += "</span>";
                }
            }
        } 
    }
    document.getElementById("lstAttachments").innerHTML = "";
    $("#lstAttachments").append(DanhSachFileDaUpLoad);
}

function DisplayFileUploadQuaKhu(ListFileName, DuongDan, id, Controller, Action) {
    var DanhSachFileDaUpLoad = "";
    var list = ListFileName.split("|");
    if (list.length > 0) {
        for (var i = 0; i < list.length; i++) {
            if (!IsEmpty(list[i])) {
                DanhSachFileDaUpLoad += "<span id='file1" + i + "'>"
                + "<a target='_self' name='summary' href='/Download/DownloadFile?fileName="
                + list[i].toString() + "&path=" + DuongDan + "' style='color: Blue;' >"
                + list[i].toString() + "</a>&nbsp;"
                + "<img title='Xóa File đính kèm' alt='Xóa File đính kèm' style='cursor:pointer' src='/Images/CrossDelete.png' onclick=\"javascript:DoDeleteAttachAjaxQuaKhu("
                + i + "," + id + ",'" + list[i] + "','" + Controller + "','" + Action + "');\" />;&nbsp&nbsp;"
                + "</span>";
            }
        }
    }
    document.getElementById("lstAttachmentsQuaKhu").innerHTML = "";
    $("#lstAttachmentsQuaKhu").append(DanhSachFileDaUpLoad);
}
function DisplayFileUploadChoTinh(ListFileName, DuongDan, id, Controller, Action) {
    document.getElementById("lstAttachments").innerHTML = "";
    var DanhSachFileDaUpLoad ="";
    var list = ListFileName.split(",");
    if (list.length > 0) {
        for (var i = 0; i < list.length; i++) {
            if (!IsEmpty(list[i])) {
                DanhSachFileDaUpLoad += "<span id='file" + i + "'>"
                + "<a target='_self' name='summary' href='/Download/DownloadFile?fileName="
                + list[i].toString() + "&path=" + DuongDan + "' style='color: Blue;' >"
                + list[i].toString() + "</a>&nbsp;"
                + "<img title='Xóa File đính kèm' alt='Xóa File đính kèm' style='cursor:pointer' src='/Images/CrossDelete.png' onclick=\"javascript:DoDeleteAttachAjax("
                + i + "," + id + ",'" + list[i] + "','" + Controller + "','" + Action + "');\" />;&nbsp&nbsp;"
                + "</span>";
            }
        }
        $("#lstAttachments").append(DanhSachFileDaUpLoad);
    } else {
        $("#lstAttachments").empty();   
    }
    
}

function DisplayFileUploadForQuaKhu(ListFileName, DuongDan) {
    var DanhSachFileDaUpLoad = "";
    var list = ListFileName.split("|");
    if (list.length > 0) {
        for (var i = 0; i < list.length; i++) {
            if (!IsEmpty(list[i])) {
                DanhSachFileDaUpLoad += "<span id='file1" + i + "'>"
                + "<a target='_self' name='summary' href='/Download/DownloadFile?fileName="
                + list[i].toString() + "&path=" + DuongDan + "' style='color: Blue;' >"
                + list[i].toString() + "</a>&nbsp;;&nbsp&nbsp;"
                + "</span>";
            }
        }
    }
    document.getElementById("lstAttachmentsQuaKhu").innerHTML = "";
    $("#lstAttachmentsQuaKhu").append(DanhSachFileDaUpLoad);
}

function DisplayFileUploadIsDeleted(ListFileName, DuongDan) {
    var DanhSachFileDaUpLoad = "";
    if (ListFileName != null) {
        var list = ListFileName.split("|");
        if (list.length > 0) {
            for (var i = 0; i < list.length; i++) {
                if (!IsEmpty(list[i])) {
                    DanhSachFileDaUpLoad += "<span id='file" + i + "'>"
                + "<a target='_self' name='summary' href='/Download/DownloadFile?fileName="
                + list[i].toString() + "&path=" + DuongDan + "' style='color: Blue;' >"
                + list[i].toString() + "</a>&nbsp;;&nbsp&nbsp;"
                + "</span>";
                }
            }
        }
    }
    document.getElementById("lstAttachments").innerHTML = "";
    $("#lstAttachments").append(DanhSachFileDaUpLoad);
}

/*Delete attachment file ajax
=============================================================*/

function DoDeleteAttachAjax(item, id, filename, Controller, Action) {
    document.getElementById("XoaFileMessage").innerHTML = "";
    if (confirm("Bạn có thực sự muốn xóa file " + filename + " ?")) {
        var url = basePath + Controller + "/" + Action + "?id=" + id + "&filename=" + filename;
        $.getJSON(url, null, function (data) {
            if (data) {
                //Xoa thanh cong
                $("span#file" + item).remove();
                //document.getElementById("XoaFileMessage").innerHTML = "Xóa file thành công ! ";
            }
            else {
                document.getElementById("XoaFileMessage").innerHTML = "Xóa file thất bại ! ";
            }
        });
    }

}

function DoDeleteAttachAjaxQuaKhu(item, id, filename, Controller, Action) {
    document.getElementById("XoaFileMessage").innerHTML = "";
    if (confirm("Bạn có thực sự muốn xóa file " + filename + " ?")) {
        var url = basePath + Controller + "/" + Action + "?id=" + id + "&filename=" + filename;
        $.getJSON(url, null, function(data) {
            if (data) {
                //Xoa thanh cong
                $("span#file1" + item).remove();
                document.getElementById("XoaFileMessageQuaKhu").innerHTML = "Xóa file thành công ! ";
            } else {
                document.getElementById("XoaFileMessageQuaKhu").innerHTML = "Xóa file thất bại ! ";
            }
        });
    }
}
/*End EventHandler*/


//Hàm chuyển đổi chuỗi ngày tháng (dd/MM/yyy) thành kiểu ngày tháng
function parseDate(str) {
    var mdy = str.split('/');
    return new Date(mdy[2], mdy[1], mdy[0]);
}

// Tam hàm dùng để lấy id giao diện và id hồ sơ

function GetIdGiaoDienAndIdHoSo() {
    var t = $("#IdGiaoDien").val() + ',' + $("#IdHoSo").val();
    return t;
}

//Hàm cộng tháng vào ngày (dd/MM/yyyy) hoặc (MM/yyyy)
function AddMonths(date, months) {
    try {
        var arrDate = date.split('/');
        if (arrDate.length == 3) {
            var Day = parseInt(DeleteAllFirstZero(arrDate[0]));
            var Month = parseInt(DeleteAllFirstZero(arrDate[1])) - 1;
            var Year = parseInt(arrDate[2]);
            var objDate = new Date(Year, Month, Day);
            objDate.setMonth(Month + parseInt(months));

            return GetDateFormatddMMyyyy(objDate);
        }
        else
            if (arrDate.length == 2) {
                var Day = 1;
                var Month = parseInt(DeleteAllFirstZero(arrDate[0])) - 1;
                var Year = parseInt(DeleteAllFirstZero(arrDate[1]));
                var objDate = new Date(Year, Month, Day);
                objDate.setMonth(Month + parseInt(months));

                return GetDateFormatMMyyyy(objDate);
            }
    }
    catch (e) {
        return date;
    }
}

//Hàm cộng ngày (dd/MM/yyyy)
function AddDays(date, days) {
    //date (dd/MM/yyyy)
    try {
        var arrDate = date.split('/');

        var Day = parseInt(DeleteAllFirstZero(arrDate[0]));
        var Month = parseInt(DeleteAllFirstZero(arrDate[1])) - 1;
        var Year = parseInt(DeleteAllFirstZero(arrDate[2]));

        var objDate = new Date(Year, Month, Day);
        objDate.setDate(Day + parseInt(days));
        return GetDateFormatddMMyyyy(objDate);
    }
    catch (e) {
        return date;
    }
}

//Lấy chuỗi ngày tháng định dạng dd/MM/yyyy từ đối tượng Date
function GetDateFormatddMMyyyy(objDate) {
    var result = "";
    if (objDate.getDate() < 10) {
        result += "0" + objDate.getDate();
    }
    else {
        result += objDate.getDate();
    }
    if (objDate.getMonth() + 1 < 10) {
        result += "/0" + (objDate.getMonth() + 1);
    }
    else {
        result += "/" + (objDate.getMonth() + 1);
    }
    result += "/" + objDate.getFullYear();
    return result;
}

//Lấy chuỗi ngày tháng định dạng MM/yyyy từ đối tượng Date
function GetDateFormatMMyyyy(objDate) {
    var result = "";
    if (objDate.getMonth() + 1 < 10) {
        result += "0" + (objDate.getMonth() + 1);
    }
    else {
        result += (objDate.getMonth() + 1);
    }
    result += "/" + objDate.getFullYear();
    return result;
}


//TAM .NN
function openboxwait() {
    $("#DialogWait").dialog({
        autoOpen: true,
        modal: true,
        width:90,
        height: 90,
        resizable: false
    });
    $('#DialogWait').prev('.ui-dialog-titlebar').hide();
    var t = $(".ui-widget-content").css('left');
    var t1 = t.split('p');
    jQuery(".ui-widget-content").css({ 'width': '59px', 'left': (parseInt(t1[0] + 100)) + 'px' });
    jQuery(".ui-dialog-content").css({ 'left': '-5px' });
    $("#DialogWait").css({ 'padding': '5px 6px 7px 6px' });
}

function closeboxwait() {
    $("#DialogWait").dialog("close");
}